export default {
    props: {
        content: {
            default: 'You can get 500 credits after connect and share the WIFI'
        },
    },
    data: {
        strList: [],
    },
    onInit() {
        this.getStrList();
    },
    /**
     * 截取单词，汉字，数字转成数组
     */
    getStrList() {
        let reg = /\w+|[^\u0000-\u00ff]+|\d+/g
        let ary = this.content.match(reg);
        ary.forEach((item) => {
            this.strList.push({
                txt: item
            })
        })
    },
    /**
     * 给指定文字设置颜色
     * @param str
     * @param color
     * @return
     */
    findAndSetStrColor(str, color) {
        console.error('----'+ str)
        this.strList.forEach((item, index) => {
            const el = this.$element(`title${index}`)
            let content = el.attr.value
            if (content === str) {
                this.strList.splice(index, 1, {
                    txt: item.txt,
                    color: color
                })
            }
        })
        console.error(JSON.stringify(this.strList))
    },

}
